var app = getApp();
//获得

var MyRequest = require("../../utils/MyRequest.js");
var Global = require("../../Global.js");

Page({
    data:{
        value1:5,
        value2:5
    },
    onLoad:function(options){
        this.setData({
            orderNo:options.orderNo,
            orderTime:options.orderTime,
            id:options.id
        });
    },
    sliderchange1:function(e){
        this.setData({
            value1:e.detail.value
        });
    },
    sliderchange2:function(e){
        this.setData({
            value2:e.detail.value
        });
    },
    submit:function(){
        if(this.data.detail == undefined || this.data.detail == ""){
            wx.showToast({
                title: '请输入评价',
                duration: 2000
            })
            return;
        }
        var user = Global.getUserStorage();
        var data = {
            action:"comment",
            orderId:this.data.id,
            content:this.data.detail,
            accountId:user.id,
            tasteScore:this.data.value1,
            speedScore:this.data.value2
        }
        MyRequest.MyGetWithToast("Comment", this,this.callBack, data);
    },
    callBack:function(result){
        var pages = getCurrentPages();
        var prevPage = pages[pages.length - 2];
        prevPage.Presenter.init(prevPage);
        wx.navigateBack();
    },
    bindTextAreaBlur:function(e){
        this.setData({
            detail: e.detail.value
        });
    }
})
